package cn.jly.bigdata.spark.core

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * @author lanyangji
 * @date 2019/11/28 14:45
 */
object Spark09_Default {

  def main(args: Array[String]): Unit = {

    val sc = new SparkContext(new SparkConf().setMaster("local[*]").setAppName("test-default-partition"))

    val listRdd: RDD[Int] = sc.makeRDD(1 to 8, 3)

    val indexRdd: RDD[(Int, Int)] = listRdd.mapPartitionsWithIndex((partitionNo, iter) => {
      iter.map((partitionNo, _))
    })

    indexRdd.foreach(println)

    sc.stop()

  }

}
